# -*- coding:utf-8 -*-

from flask import Flask,jsonify,render_template
from wsgiref.simple_server import make_server


app = Flask(__name__)

@app.route('/users/<name>')
def data(name):
    users = [
        {"name": "Tom", "age": "18", "sex": 1},
        {"name": "Coral", "age": "17", "sex": 0},
        {"name": "Kate", "age": "18", "sex": 0}
    ]
    for user in users:
        if user['name'].lower() == name.lower():
            return jsonify(user)

    return jsonify({"errMsg": "can not find the user!"})

@app.route('/users/')
def userlist(users=None):
    return render_template('userlist.html',users=users)

if __name__ == '__main__':
    # server = make_server('127.0.0.1', 5000, app)
    # server.serve_forever()
    app.run()



